#include<iostream>
#include<vector>
#include<string>
#include<stack>

using namespace std;

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        int i = 0;
        stack<int> s;
        while (i < tokens.size())
        {
            if (tokens[i] != "+" && tokens[i] != "-" && tokens[i] != "*" && tokens[i] != "/")
            {
                s.push(stoi(tokens[i]));
                i++;
            }
            else
            {
                int right = s.top();
                s.pop();
                int left = s.top();
                s.pop();
                if (tokens[i] == "+")
                {
                    s.push(left + right);
                    i++;
                    continue;
                }
                if (tokens[i] == "-")
                {
                    s.push(left - right);
                    i++;
                    continue;

                }
                if (tokens[i] == "*")
                {
                    s.push(left * right);
                    i++;
                    continue;

                }
                if (tokens[i] == "/")
                {
                    s.push(left / right);
                    i++;
                    continue;

                }
            }
        }
        return s.top();
    }
};
int main()
{
    Solution s;
    vector<string> v = { "10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+" };
    s.evalRPN(v);
    return 0;
}